package com.wash.shoes.controller.pc;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.wash.shoes.domain.vo.RegionWashShopVo;
import com.wash.shoes.entity.RegionWashShopPo;
import com.wash.shoes.service.RegionWashShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhengyunpeng
 * @since 2024-08-27
 */
@Api(tags = {"PC-区域清洗的门店配置"})
@RestController
@RequestMapping("/regionWashShop")
public class RegionWashShopController {

    @Autowired
    RegionWashShopService regionWashShopService;

    @ApiOperation("获取列表")
    @PostMapping("/list")
    public R<Page<RegionWashShopVo>> pageList(@RequestBody RegionWashShopPo regionWashShopPo) {
        Page<RegionWashShopVo> page = regionWashShopService.pageList(regionWashShopPo);
        return R.ok(page);
    }


    @ApiOperation("保存")
    @PostMapping("/save")
    public R<RegionWashShopPo> save(@RequestBody RegionWashShopPo regionWashShopPo) {
        regionWashShopService.save(regionWashShopPo);
        return R.ok(regionWashShopPo);
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public R<RegionWashShopPo> update(@RequestBody RegionWashShopPo regionWashShopPo) {
        regionWashShopService.updateById(regionWashShopPo);
        return R.ok(regionWashShopPo);
    }

    @ApiOperation("真删除")
    @PostMapping("/deleteByStatus")
    public R<RegionWashShopPo> deleteByStatus(String theId) {
        RegionWashShopPo regionWashShopPo = regionWashShopService.getById(theId);
        regionWashShopService.removeById(regionWashShopPo);
        // 修改状态为0 ，如果需要判断是否能删除，后期处理
        return R.ok(regionWashShopPo);
    }

    @ApiOperation("获取详情")
    @PostMapping("/getDetailById")
    public R<RegionWashShopPo> getDetailById(String theId) {
        RegionWashShopPo regionWashShopPo = regionWashShopService.getById(theId);
        return R.ok(regionWashShopPo);
    }

}

